package cn.edu.xmu.restfuldemo.model.VO;

import cn.edu.xmu.restfuldemo.model.BO.GoodsSku;
import cn.edu.xmu.restfuldemo.model.VoObject;
import lombok.*;

import java.time.LocalDateTime;

/**
 * @author RenJie Zheng
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class GoodsSkuRetVo implements VoObject {
    private Long id;
    private Long goodsSpuId;
    private String skuSn;
    private String name;
    private Long originalPrice;
    private String configuration;
    private Long weight;
    private String imageUrl;
    private Integer inventory;
    private String detail;
    private Byte disabled;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;
    private Byte state;

    public GoodsSkuRetVo(GoodsSku goodsSku){
        this.id=goodsSku.getId();
        this.goodsSpuId=goodsSku.getGoodsSpuId();
        this.skuSn=goodsSku.getSkuSn();
        this.name=goodsSku.getName();
        this.originalPrice=goodsSku.getOriginalPrice();
        this.configuration=goodsSku.getConfiguration();
        this.weight=goodsSku.getWeight();
        this.imageUrl=goodsSku.getImageUrl();
        this.inventory=goodsSku.getInventory();
        this.detail=goodsSku.getDetail();
        this.disabled=goodsSku.getDisabled();
        this.gmtModified=goodsSku.getGmtModified();
        this.gmtCreate=goodsSku.getGmtCreate();
        this.state=goodsSku.getState();
    }

    /**
     * gooksSkuRetVo->goodsSku
     * @return
     */
    public GoodsSku newGoodsSkuFromVo(){
        GoodsSku goodsSku = new GoodsSku();
        goodsSku.setId(this.id);
        goodsSku.setGoodsSpuId(this.goodsSpuId);
        goodsSku.setSkuSn(this.skuSn);
        goodsSku.setName(this.name);
        goodsSku.setOriginalPrice(this.originalPrice);
        goodsSku.setConfiguration(this.configuration);
        goodsSku.setWeight(this.weight);
        goodsSku.setImageUrl(this.imageUrl);
        goodsSku.setInventory(this.inventory);
        goodsSku.setDetail(this.detail);
        goodsSku.setDisabled(this.disabled);
        goodsSku.setGmtCreate(this.gmtCreate);
        goodsSku.setGmtModified(this.gmtModified);
        goodsSku.setState(this.state);
        return goodsSku;
    }

    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() {
        return this;
    }
}
